package com.lzh.others.basejava.Anotation_20;

import java.util.Collections;
import java.util.List;

/**
 * @Classname PasswordUtils
 * @Description TODO
 * @Date 2021/11/1 10:31
 * @Created by liuzihao
 */
public class PasswordUtils {

    private final static String PASSWORD = "123456";

    @UseCase(id = 47, description =
            "Passwords must contain at least one numeric")
    public static boolean validatePassword(String pasword) {
        return (pasword.matches("\\w*\\d\\w*"));
    }

    @UseCase(id = 48)
    public static String encryptPassword(String password) {
        return new StringBuilder(password).reverse().toString();
    }

    @UseCase(id = 49, description =
            "New paswords can't equal previously used ones")
    public static boolean checkForNewPassword(List<String> prevPasswords, String password) {
        return !prevPasswords.contains(password);
    }

    public static void main(String[] args) {
        List<String> prevPasswords = Collections.singletonList("123456");
        System.out.println(PasswordUtils.validatePassword(PASSWORD));
        System.out.println(PasswordUtils.encryptPassword(PASSWORD));
        System.out.println(PasswordUtils.checkForNewPassword(prevPasswords, PASSWORD));
    }
}
